package cn.tedu.cool.controller;

import cn.tedu.cool.entity.Data;
import cn.tedu.cool.entity.Data_s;
import cn.tedu.cool.entity.Good;
import cn.tedu.cool.mapper.DataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DataController {
@Autowired(required = false)
    DataMapper dataMapper;

@RequestMapping("/Data/select")
public List<Data> select(){
return dataMapper.select();
}
    @RequestMapping("/data/select")
    public List<Data_s> sel(){
        return dataMapper.sel();
    }
@RequestMapping("/Good/select")
    public List<Good> cx(){
    return dataMapper.cx();
}
@RequestMapping("/p1/select")
    public int cp(){
   Data data = dataMapper.dd();
    int sum =data.getDapay()+data.getDavis()+data.getDauser()+data.getDapur();
    data.setDasum(sum);
    int q = data.getDapay()*100/data.getDasum();
     return q;
}
    @RequestMapping("/p2/select")
    public int cd(){
        Data data = dataMapper.dd();
        int sum =data.getDapay()+data.getDavis()+data.getDauser()+data.getDapur();
        data.setDasum(sum);
        int w = data.getDavis()*100/data.getDasum();
        return w;
    }
    @RequestMapping("/p3/select")
    public int cf(){
        Data data = dataMapper.dd();
        int sum =data.getDapay()+data.getDavis()+data.getDauser()+data.getDapur();
        data.setDasum(sum);
        int e = data.getDauser()*100/data.getDasum();
        return e;
    }
    @RequestMapping("/p4/select")
    public int cg(){
        Data data = dataMapper.dd();
        int sum =data.getDapay()+data.getDavis()+data.getDauser()+data.getDapur();
        data.setDasum(sum);
        int r = data.getDapur()*100/data.getDasum();
        return r;
    }
}
